Hi Toby,
I'm not sure. The examples like SimpleFormsCS seem to work fine. You might look at how it gets status and detects errors and compare it to your methods.
Otherwise we would need examples of what your code is doing.
Regards TK
Group: DynoMotion |
Message: 8095 |
From: Toby Rule |
Date: 8/14/2013 |
Subject: Re: WaitToken returns KMOTION_IN_USE after USB cable is disconnected |
Hi Tom,
Thanks for your reply. The problem is that after the board is disconnected and I try to do “CheckBoards()” or “CheckConnected” or some other function to check
if the board is connected, it deadlocks, at least occasionally. I presume I am calling a function in a timer that is being interrupted, and not releasing the lock. In order to get around the deadlock on disconnect, I started checking for the presence of
the USB device directly using ManagementObject, which allowed me to detect a disconnected board without deadlocking, but then apparently the lock remains, and it deadlocks when I re-connect.
I may have to start turning off timers until I find the one that is firing the code that is keeping the lock.
Toby
Group: DynoMotion |
Message: 8098 |
From: Tom Kerekes |
Date: 8/15/2013 |
Subject: Re: WaitToken returns KMOTION_IN_USE after USB cable is disconnected |
Hi Toby,
Could you change your code to do it the way the SimpleFormsCS example does it?
It doesn't use those methods.
Regards TK
Group: DynoMotion |
Message: 8102 |
From: Toby Rule |
Date: 8/15/2013 |
Subject: Re: WaitToken returns KMOTION_IN_USE after USB cable is disconnected |
It appear that SimpleFormsCS has a loop that runs GetBoards() to determine if it is connected. I changed my loop to call GetBoards() too, exactly the same
as SimpleFormCS. But it still tends to hang on the GetBoards() call when the board is disconnected.
Toby
Group: DynoMotion |
Message: 8105 |
From: Tom Kerekes |
Date: 8/15/2013 |
Subject: Re: WaitToken returns KMOTION_IN_USE after USB cable is disconnected |
Hi Toby,
Just as a sanity check can you run the SimpleFormsCS.exe example (it should exist in the KMotion\Release directory) and disconnect and re-connect and make sure it works correctly on your system.
But otherwise it seems the code is not releasing the Token somewhere on a disconnect. Since a disconnect may happen at any time every operation must be written to expect it. Checking if the board is connected before doing an operation is not sufficient because the disconnect might occur after the test.
Regards TK
Group: DynoMotion |
Message: 8107 |
From: Toby Rule |
Date: 8/16/2013 |
Subject: Re: WaitToken returns KMOTION_IN_USE after USB cable is disconnected |
Hi Tom,
I tried running SimpleFormsCS.exe and it seems to work OK. Also, KMotion.exe works OK with disconnect/reconnect. Only my code doesn’t work. I’m sure my code
never takes a token it doesn’t release – I only added calls to WaitToken()/ReleaseToken() once I started troubleshooting this problem. I have some timers that access the board using other KMotion methods. I will try disabling all the timers and see if that
gives me a clean re-connect.
Toby
Group: DynoMotion |
Message: 8115 |
From: Toby Rule |
Date: 8/16/2013 |
Subject: Re: WaitToken returns KMOTION_IN_USE after USB cable is disconnected |
Hi Tom,
After some more work, it appears that if I properly implement the method in SimpleFormsCS.exe, it will re-connect without hanging.
Thanks for the suggestions!
Toby
| | | | | | | | | | | | | |